package com.ssy.lingxi.purchase.api.enums.purchase;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 采购报价单-操作枚举类
 *
 * @author lxc
 * @date 2022/2/25
 */
public enum QuoteOperationEnum {

    ADD_QUOTE(1, "新增报价单"),
    UPDATE_QUOTE(2, "修改报价单"),
    SUBMIT_CHECK_QUOTE(3, "提交审核报价单"),
    CHECK_QUOTE_1(4, "审核报价单(一级)"),
    CHECK_QUOTE_2(5, "审核报价单(二级)"),
    SUBMIT_QUOTE(6, "提交报价单"),
    ;
    /**
     * 状态
     */
    private Integer state;

    /**
     * 描述
     */
    private String name;

    public static String getName(Integer state){
        QuoteOperationEnum workEnum = Arrays.stream(QuoteOperationEnum.values()).filter(v -> v.getState().equals(state)).findAny().orElse(null);
        return null == workEnum ? "" : LanguageHolder.getName(QuoteOperationEnum.class, workEnum.getState());
    }

    public static String getName(String name){
        QuoteOperationEnum workEnum = Arrays.stream(QuoteOperationEnum.values()).filter(v -> v.getCHName().equals(name)).findAny().orElse(null);
        return null == workEnum ? "" : LanguageHolder.getName(QuoteOperationEnum.class, workEnum.getState());
    }

    QuoteOperationEnum(Integer state, String name) {
        this.state = state;
        this.name = name;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    /**
     * 针对字段类型为Integer
     * @return
     */
    public String getName() {
        return LanguageHolder.getName(this.getClass(), this.state);
    }
    
    /**
     * 针对字段类型为String
     * @return
     */
    public String getCHName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
